
#pragma once
#include <stdint.h>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
#include "util.hpp"
typedef websocketpp::server<websocketpp::config::asio> wsserver_t;

typedef enum
{
    UNLOGIN,
    LOGIN
} ss_status; // session 状态

// 实现一个session类，并且如果长时间未连接，就销毁session对象
class session
{
public:
    session(uint64_t ssid)
        : _ssid(ssid)
    {
        DBG_LOG("session_manager %p init!", this);
    }
    ~session()
    {
        DBG_LOG("session_manager %p destroy!", this);
    }
    void set_uid(uint64_t uid)
    {
        _uid = uid;
    }
    void set_status(ss_status status)
    {
        _status = status;
    }
    void set_timer(const wsserver_t::timer_ptr &tp)
    {
        _tp = tp;
    }
    uint64_t get_ssid()
    {
        return _ssid;
    }
    uint64_t get_uid()
    {
        return _uid;
        ;
    }
    bool is_login()
    {
        return _status == ss_status::LOGIN;
    }
    wsserver_t::timer_ptr &get_timer()
    {
        return _tp;
    }

private:
    uint64_t _ssid;            // session id
    uint64_t _uid;             // session id 对应的用户id
    ss_status _status;         // session 状态  0未登录 1登录
    wsserver_t::timer_ptr _tp; // session关联的定时器
};